﻿Public Class Rcorredora

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Ecorredora)
        Dim corredoras As List(Of Ecorredora) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                corredoras = Dcorredora.SeleccionarTodo(descEmpresa)
                If corredoras Is Nothing Then corredoras = New List(Of Ecorredora)
                If DisplaySelect Then corredoras.Insert(0, New Ecorredora("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return corredoras
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Ecorredora)
        Dim corredoras As List(Of Ecorredora) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                corredoras = Dcorredora.SeleccionarXEstado(descEmpresa)
                If corredoras Is Nothing Then corredoras = New List(Of Ecorredora)
                If DisplaySelect Then corredoras.Insert(0, New Ecorredora("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return corredoras
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pCorredora As Ecorredora) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcorredora.Añadir(descEmpresa, pCorredora)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pCorredora As Ecorredora) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcorredora.Editar(descEmpresa, pCorredora)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pCorredora As Ecorredora) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcorredora.Eliminar(descEmpresa, pCorredora)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
